#!/usr/bin/python

import warper
import sys

def main(argv):
    warper.GtkInit()

    if len(argv) >= 2:
        infile = argv[1]
    else:
        infile = "../test/Grid.png"
    if len(argv) >= 3:
        outfile = argv[2]
    else:
        outfile = "Test.png"

    settings = warper.Settings()
    settings.custom_width = 200
    settings.custom_height = 200

    print "Opening", infile
    manager = warper.Manager()
    manager.LoadImage(infile)
    print "Transforming"
    manager.TransformBegin(settings, 100000, 0.01)
    while not manager.TransformFinished():
        print manager.TransformFraction() * 100
        manager.TransformStep()
    print manager.TransformFraction() * 100
    print "Saving PNG to", outfile
    manager.SaveOutput(outfile, "png")

    warper.GtkDestroy()

if __name__ == '__main__':
    main(sys.argv)

